<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <body>
        <ui:composition template="./../template.xhtml">
            <link href="#{appBean.baseUrl}resources/css/cambioClave.css" type="text/css" rel="alternate" />
            <ui:define name="content">
                <center>
                    <div class="conteiner" >
                        <h:form id="formcambioClave" style="text-align: center;">  
                            <p:spacer height="10" />  
                            <p:growl id="growl" showDetail="true"/>
                            <p:panel header="Cambio de Clave">  
                                <br />
                                <p:messages id="messages" showDetail="true"/>  

                                <h:panelGrid columns="2" id="matchGrid" style="text-align: center;">       

                                    <h:outputLabel for="pwd1" value="Clave 1: *" />  
                                    <p:password id="pwd1" value="#{cambioClaveBean.password1}" match="pwd2" label="Password 1" feedback="true" required="true"
                                                promptLabel="Ingrese su nueva clave" 
                                                weakLabel="Debil" goodLabel="Buena" strongLabel="Segura"/>  

                                    <h:outputLabel for="pwd2" value="Clave 2: *" />  
                                    <p:password id="pwd2" value="#{cambioClaveBean.password1}" label="Password 2" feedback="true" required="true"
                                                promptLabel="Reingrese su nueva clave"
                                                weakLabel="Debil" goodLabel="Buena" strongLabel="Segura"/>  
                                    <br />
                                </h:panelGrid>  
                                <p:commandButton id="saveButton" update="matchGrid" value="Guardar"
                                                 actionListener="#{cambioClaveBean.password2}" icon="icon-cambioClave"
                                                 oncomplete="handleCambioClaveRequest(xhr, status, args)"/>
                                <br /><br />
                            </p:panel>
                            <p:spacer height="10" /> 
                        </h:form>
                    </div>
                </center>
            </ui:define>
        </ui:composition>
        <script type="text/javascript">
            function handleCambioClaveRequest(xhr, status, args) {  
                if(args.validationFailed || !args.loggedIn) {
                    jQuery("#formcambioClave").effect("shake", { times:5 }, 100);
                    }
                else {
                    location.href = args.ruta;
                    }
            }
//            function verif(formu) {	
//                if (formu.c1.value==formu.c2.value) 
//                   { alert('las contraseñas coinciden'); 
//                       return true; }
//                   else { 
//                       alert('las dos contraseñas no son iguales'); 
//                       return false; }
//                   }
        </script>
    </body>
</html>